package cn.gok.springbootdemo06.config;

import cn.gok.springbootdemo06.Interceptor.MyInterceptorHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
    自定义的mvc的配置
 */
@Configuration
public class MyfWebMvcConfig implements WebMvcConfigurer {

    /**
     * 将自定义的拦截器添加在该方法中
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        MyInterceptorHandler myInterceptorHandler = new MyInterceptorHandler();
        registry.addInterceptor(myInterceptorHandler)
                //排除哪些请求
                .excludePathPatterns("/interceptTest03")
                //指定哪些请求被拦截
                .addPathPatterns("/intercept/**")
                //调节拦截器的执行顺序
                .order(1);
    }
}
